{block #mainTitle}Vzorkovna - obrázky{/block}
{block #head}{/block}
{block #content}
    <div id="dialog-confirm" style="display:none;">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;">
            </span>Opravdu si přejete obrázek odstranit?
        </p>
    </div>

    {control imageForm}

    <h2>Obrázky</h2>
    <table class="data-table" n:if="count($images)">    
        <thead>
            <tr>
                <th>ID</th>
                <th>Název</th>
                <th>Popis</th>
                <th>Obrázek</th>
                <th>Akce</th>
            </tr>
        </thead>
        <tbody>        
            <tr n:foreach="$images as $image">
                <td>{$image->id_image}</td>
                <td>{$image->title}</td>
                <td>{$image->description|truncate:40}</td>
                <td><img src="{imageThumbPath $image->id_image}" /></td>                
                <td>
                    <a class="action-icon-delete" href="{link smazatObrazek!, $showroom->id_showroom, $image->id_image}">Smazat</a>
                </td>
            </tr>        
        </tbody>
        <script type="text/javascript">
            initButtons();
            initAjaxLinks();

            $(function() {
                $(".action-icon-delete").bind('click', showModal);
                function showModal() {
                    var link = this.href;                
                    $('#dialog-confirm').dialog({
                            modal: true,
                            closeText: 'zavřít',
                            title: 'Smazání položky',
                            buttons: {
                                'Ano':function(event) {
                                    event.preventDefault();
                                    $.get(link);
                                    $(this).dialog('close');
                                },
                                'Ne': function() {
                                    $(this).dialog('close');
                                }
                            }
                    });
                    return false;
                };
            });
        </script>
    </table>
    
{/block}

